package com.example.sonone.error;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@Controller
@RequestMapping("/error")
public class ErrorController {
	
	@ResponseBody
	@RequestMapping(value = "/400")
	public ServerResponse paramError(HttpServletRequest request, HttpServletResponse response) {
		return ServerResponse.createErrorException(400, "请求参数有误");
	}

	@ResponseBody
	@RequestMapping(value = "/404")
	public ServerResponse uriError(HttpServletRequest request, HttpServletResponse response) {
		return ServerResponse.createErrorException(404, "路径错误");
	}

	@ResponseBody
	@RequestMapping(value = "/500")
	public ServerResponse serviceError(HttpServletRequest request, HttpServletResponse response) {
		return ServerResponse.createErrorException(500, "服务器繁忙，请稍后重试");
	}
}